<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}
if($_POST['sub']!=''){
    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
    
    if(empty($_POST["type"])){
        
        jumpajax('300','角色不能为空!','');
    }
    if(empty($_POST["cuisine"])){
        
        jumpajax('300','菜系不能为空!','');
    }
    if(empty($_POST["name"])){
        
        jumpajax('300','姓名/名称不能为空!','');
    }
    if(empty($_POST["telephone"])){
        
        jumpajax('300','联系电话不能为空!','');
    }
    
    $status=intval($_REQUEST["status"]);
    $p=0;
    //
	$data=array(
        'type'=>trim($_POST["type"]),
        'cuisine'=>trim($_POST["cuisine"]),
        'name'=>trim($_POST["name"]),
        'thumb'=>trim($_POST["imgs0_fileName"]),
        'pic'=>trim($_POST["imgs1_fileName"]),
        'telephone' => trim($_POST["telephone"]),
        'description1' => trim($_POST["description1"]),
        'description2' => trim($_POST["description2"]),
        'description3' => trim($_POST["description3"]),
        'status'=>$status,
    );
 	if($id==0){
            $data['createtime']=time();
               $id=$ezhand->insert("shopping3_chef",$data);
		jumpajax('200','资料保存成功','page458','closeCurrent');
	}else{
	    $ezhand->update("shopping3_chef",$data,'id="'.$id.'"');
		jumpajax('200','资料修改成功','page458','closeCurrent');
	}
}else{
        $rolelist=array('0'=>'请选择角色','1'=>'厨师','2'=>'名店');
        $cuisinelist=$ezhand->getcuisinelist();
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
    if($id==0){
	    $row=array();
        $dishes=array();
        $row["status"]=1;
	}else{
	   
	    $row=$ezhand->select("shopping3_chef",'*','id="'.$id.'"');
        
	}
}
?>